from django.test import TestCase
from django.test import Client
from login.models import User
from django.urls import reverse
# Create your tests here.



class UserModelTest(TestCase):
    def setUp(self):
        self.test_user = User.objects.create_user(
            username='test_user',
            password='003416',
            email='1327000506@qq.com',
            phone='15364149863'
        )

    def test_create_user(self):
        self.assertTrue(isinstance(self.test_user,User))






class UserLogin(TestCase):
    def setUp(self):
        self.test_user = User.objects.create_user(
            username='test_user2',
            password='111458',
            email='1327560226@qq.com',
            phone='15160639863'
        )

        self.client = Client()
        self.login_url = reverse('login')



    def test_login(self):

        data = {
            'username':'test_user2',
            'password':'111458'
        }
        res = self.client.post(self.login_url,data,format('json'))
        self.assertEqual(res.status_code ,200)




